package com.xqt.service.message;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.xqt.base.dao.BaseDao;
import com.xqt.base.entity.BaseEntity;
import com.xqt.base.service.BaseService;
import com.xqt.dao.message.MessageBaseDao;
import com.xqt.entity.message.MessageBase;
import com.xqt.inters.service.message.IMessageService;



public class MessageBaseService extends BaseService<MessageBase> implements IMessageService {

	@Autowired
	MessageBaseDao messageBaseDao;
	
	@Override
	public void add(MessageBase t) throws Exception {
		messageBaseDao.add(t);
	}

	public void update(MessageBase t) throws Exception {
		preUpdate(t);
		messageBaseDao.updateBySelective(t);
	}

	@Override
	public void delete(Object... ids) {
		if(null == ids || ids.length < 1){
			return ;
		}
		for(Object id : ids){
			messageBaseDao.delete(id);
		}
	}


	@Override
	public void updateBySelective(MessageBase t) throws Exception {
		messageBaseDao.updateBySelective(t);
	}

	@Override
	public int queryByCount(BaseEntity page) {
		return messageBaseDao.queryByCount(page);
	}

	@Override
	public List<MessageBase> queryByList(BaseEntity page) {
		return messageBaseDao.queryByList(page);
	}

	@Override
	public List<MessageBase> queryList(BaseEntity page) {
		return messageBaseDao.queryList(page);
	}

	@Override
	public void saveOrUpdate(MessageBase messageBase) {
		if(StringUtils.isBlank(messageBase.getId())){
			preInsert(messageBase);
			messageBaseDao.add(messageBase);
		}else{
			try {
				preUpdate(messageBase);
			} catch (Exception e) {
				e.printStackTrace();
			}
			messageBaseDao.updateBySelective(messageBase);
		}

	}

	@Override
	public void delete(MessageBase messageBase) {
		messageBaseDao.delete(messageBase);

	}

	@Override
	public int queryCount(MessageBase messageBase) {
		return messageBaseDao.queryCount(messageBase);
	}

	@Override
	public BaseDao<MessageBase> getDao() {
		return messageBaseDao;
	}

}
